<template>
  <div style="display: inline">
    <el-button @click="ignoreOrder" type="info" :disabled="orderIds.length === 0" class="mgr10 mgb10">{{type === 1 ? $t('order.ignore') : $t('order.ignoreSelection')}}</el-button>
  </div>
</template>

<script>

import {ignoreOrder} from "@/api/order";

export default {
  name: "IgnoreOrder",
  props:{
    orderIds:{
      type: Array,
      require: true,
    },
    type: {
      default: 1,
    },
    accountTypeNum: {
      default: 1,
    }
  },
  data(){
    return {

    };
  },
  methods:{
    ignoreOrder() {
      let title = this.$t('order.Are you sure to ignore this order?');
      let html = `${this.$t('order.Ignore this order')}<br/>${this.$t('order.ignoreText1')}<br/>${this.$t('order.ignoreText2')}<br/><span style="color: #FF0000">${this.$t('order.ignoreText3')}</span>`
      if(this.type === 2){
        title = this.$t('order.Are you sure to ignore the selected order?');
        html = `${this.$t('order.ignoreText4')}<br/>${this.$t('order.ignoreText1')}<br/>${this.$t('order.ignoreText2')}<br/><span style="color: #FF0000">${this.$t('order.ignoreText4')}</span>`
      }
      this.$confirm(html, title, {
        dangerouslyUseHTMLString: true,
        confirmButtonText: this.$t('common.confirm'),
        cancelButtonClass: this.$t('common.cancel')
      })
        .then(res=>{
          // 点击了确定
          const postData = {
            orderIds : this.orderIds,
            accountTypeNum: this.accountTypeNum,
          }
          ignoreOrder(postData)
            .then(res=>{
              if(res.error === 0){
                this.$successMessage(res.message)
                this.$emit('changeOrder',true)
              }else{
                this.$errorMessage(res.message)
              }
            })
        })
        .catch(res=>{
          // 点击了取消
        });
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
